const express= require('express');
const app =express();
const debug = require("debug")("my-application")
const router = require('./router.js')
const bodyParser = require('body-parser')
const cors =require('cors')


app.use(express.static('public'))
app.use(bodyParser.urlencoded({extended:true}))
app.use(cors())


app.use('/api',router)
// cors跨域处理
app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "http://localhost:5000");
    res.header("Access-Control-Allow-Headers", "Content-Type,Access-Token");
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By",' 3.2.1');
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
})

app.listen(5000,function(){
    debug(5000)
})